var module = argument0;
var structure = argument1;
var output = instance_create(0, 0, obj_Module);

var halfStructWidth = round(array_length_2d(structure.tiles, 0) / 2);
var halfStructHeight = round(array_height_2d(structure.tiles) / 2);

output.tileX = module.tileX - halfStructWidth;
output.tileY = module.tileY - halfStructHeight;

//Handle negative case?

var outputWidth = array_length_2d(module.tiles, 0) + halfStructWidth * 2;
var outputHeight = array_height_2d(module.tiles) + halfStructHeight * 2;

for(var yyy = 0; yyy < outputHeight; yyy++)
{
    for(var xxx = 0; xxx < outputWidth; xxx++)
    {
        structure.tileX = xxx + output.tileX;
        structure.tileY = yyy + output.tileY; //check output space
        
        if(absCheckOverlap(module, structure))
        {
            //add in relative space
            structure.tileX = xxx;
            structure.tileY = yyy;
            layerModule(output, structure);
        }
    }
}

return output;